# Maintainer: David Runge <dvzrv@archlinux.org>

_name=PyMySQL
pkgname=python-pymysql
pkgver=1.0.3
pkgrel=2
pkgdesc="Pure Python MySQL Client"
arch=(any)
url="https://github.com/PyMySQL/PyMySQL/"
license=(MIT)
depends=(python)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  mariadb
  python-pytest
)
optdepends=(
  'mariadb: for using a local MariaDB instance'
  'python-cryptography: for RSA cryptography'
  'python-pynacl: for ed25519 cryptography'
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('0095c65290a15061a136b797304c3c46dae4cae8bd42603be2abdf6f1f91cc3d6b418614376c1c67321ac9ce937000e6879c29db38089fa05f815b21cd59d6cd')
b2sums=('11b106f64d7e8cada56b63ee89e4d68ad1b7a1d46bea2b041d91e453982f56d75803ec4a6f21cc901279c32f3fb23c9a0704e1495e3c87531685b991e692e878')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

# NOTE: tests require a running instance of mariadb
# check() {
#   local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

#   cd $_name-$pkgver
#   python -m installer --destdir=test_dir dist/*.whl
#   export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"
#   pytest -vv
# }

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {CHANGELOG,README}.md -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
